/*
**  Copyright (c) 2014 Michael Liu(michael.liu.point@gmail.com).
**
**  Project: Gateway Unified Management Platform
**  File:      mtk7620_local.h
**  Author:  Michael
**  Date:    07/07/2014
**
**  Purpose:
**    platform mtk7620 local defines.
*/

#ifndef __PLATFORM_MTK7620_LOCAL_H__
#define __PLATFORM_MTK7620_LOCAL_H__

#ifdef __cplusplus
extern "C" {
#endif				/* __cplusplus */

/* Include files. */

#include "common.h"
#include "dpmgr.h"
#include "eamgr.h"
#include "samgr.h"
#include "osdep.h"
#include "pfdep.h"

#include "nvram.h"

#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/autoconf.h>
#include <linux/wireless.h>
#include <iwpriv.h>

/* Macro constant definitions. */

#define MTK_GPIO_DEVICE			"/dev/gpio"

#define NVRAM_CFG_KEY_SIZE		(32)
#define NVRAM_CFG_VALUE_SIZE	(1024)
#define GET_LINE_BUF_SIZE		(1024)

#define PF_DEP_MTD_KERNEL_PART_SIZ		CONFIG_MTD_KERNEL_PART_SIZ
#define PF_DEP_DOWNLOAD_URL_SIZE		(128)
#define PF_DEP_DOWNLOAD_NAME_SIZE		(32)
#ifndef MAP_FAILED
#define MAP_FAILED 				(-1)
#endif

#define NVRAM_CFG_CHECK_KEY		"CfgCheck"
#define NVRAM_CFG_CHECK_VAL		'Y'

#define DEVICE_OPERATION_MODE	"optmode"

#define DEVICE_LED_POWER_SAVE	"led_pwr_save"
#define LED_POWER_SAVE_ON		'Y'
#define LED_POWER_SAVE_OFF		'N'

#define NETCFG_CT_KEY			"%s_conntype"
#define NETCFG_MTU_KEY			"%s_mtu"
#define NETCFG_MANUAL_DNS_KEY	"%s_man_dns"
#define NETCFG_DNS1_KEY			"%s_dns1"
#define NETCFG_DNS2_KEY			"%s_dns2"

#define NETCFG_DHCPD_TYPE_KEY			"%s_dhcpd_type"
#define NETCFG_DHCPD_POOL_START_KEY		"%s_dhcpd_start"
#define NETCFG_DHCPD_POOL_END_KEY		"%s_dhcpd_end"
#define NETCFG_DHCPD_NETMASK_KEY		"%s_dhcpd_mask"
#define NETCFG_DHCPD_DEFAULT_GW_KEY		"%s_dhcpd_gw"
#define NETCFG_DHCPD_LEASE_KEY			"%s_dhcpd_lease"
#define NETCFG_DHCPD_DNS1_KEY			"%s_dhcpd_dns1"
#define NETCFG_DHCPD_DNS2_KEY			"%s_dhcpd_dns2"

#define CONNTYPE_VAL_PPPOE		"pppoe"
#define CONNTYPE_VAL_PPTP		"pptp"
#define CONNTYPE_VAL_PPP		"ppp"
#define CONNTYPE_VAL_DHCP		"dhcp"
#define CONNTYPE_VAL_STATIC		"static"
#define CONNTYPE_VAL_NONE		"none"

#define CT_STATIC_IP_KEY		"%s_ip"
#define CT_STATIC_MASK_KEY		"%s_mask"
#define CT_STATIC_GW_KEY		"%s_gw"

#define CT_PPTP_USERNAME_KEY	"%s_pptp_user"
#define CT_PPTP_PASSWORD_KEY	"%s_pptp_pswd"
#define CT_PPTP_SERVERIP_KEY	"%s_pptp_server"

#define CT_PPPOE_CONN_TYPE_KEY	"%s_pppoe_conntype"
#define CT_PPPOE_USERNAME_KEY	"%s_pppoe_user"
#define CT_PPPOE_PASSWORD_KEY	"%s_pppoe_pswd"

#define CT_PPPOE_CONN_TYPE_STAY_VAL		"stay"
#define CT_PPPOE_CONN_TYPE_MANUAL_VAL	"manual"

#define ADMIN_PASSWORD_KEY	"Password"
#define QIS_DONE_KEY		"qis_done"
#define WEB_UI_LANGUAGE		"Language"
#define NTPSERVERIP			"NTPServerIP"
#define TIMEZONE			"TZ"

#define WLAN_24G_AP_IF		"ra0"
#define WLAN_5G_AP_IF		"rai0"
#define WLAN_24G_CLI_IF		"apcli0"
#define WLAN_5G_CLI_IF		"apclii0"

#define WLAN_24G_CLI_CONN_STATUS_FILE	"/tmp/apcli2g_connStatus.txt"
#define WLAN_5G_CLI_CONN_STATUS_FILE	"/tmp/apcli5g_connStatus.txt"
#define TIMEZONECFGFILE					"/etc/TZ"
#define FW_INFO							"/tmp/AP4100W_fwinfo"
//#define FW_INFO_URL                                           "ftp://Askeyfota:d400fota@192.168.1.33/AP-4100W/"
#define FW_INFO_URL						"ftp://Askeyfota:d400fota@ftp.askey.com.tw/AP-4100W-skysoft/AP4100W_fwinfo"
#define FW_NAME							"/tmp/AP4100W"
//#define FW_URL                                                        "ftp://Askeyfota:d400fota@192.168.1.33/AP-4100W/AP4100W"
#define FW_URL							"ftp://Askeyfota:d400fota@ftp.askey.com.tw/AP-4100W-skysoft/"

#define WLAN_AUTH_MODE_OPEN				"OPEN"
#define WLAN_AUTH_MODE_SHARED			"SHARED"
#define WLAN_AUTH_MODE_WEPAUTO			"WEPAUTO"
#define WLAN_AUTH_MODE_WPAPSK			"WPAPSK"
#define WLAN_AUTH_MODE_WPANONE			"WPANONE"
#define WLAN_AUTH_MODE_WPA2PSK			"WPA2PSK"
#define WLAN_AUTH_MODE_WPAPSKWPA2PSK	"WPAPSKWPA2PSK"
#define WLAN_AUTH_MODE_WPA				"WPA"
#define WLAN_AUTH_MODE_WPA2				"WPA2"
#define WLAN_AUTH_MODE_WPAWPA2			"WPAWPA2"

#define WLAN_ENC_METHOD_NONE			"NONE"
#define WLAN_ENC_METHOD_WEP				"WEP"
#define WLAN_ENC_METHOD_TKIP			"TKIP"
#define WLAN_ENC_METHOD_AES				"AES"
#define WLAN_ENC_METHOD_TKIP_AES		"TKIPAES"

#define WLAN_ENC_METHOD_TKIP_AES_MIX_1		"WPA_AES_WPA2_TKIP"
#define WLAN_ENC_METHOD_TKIP_AES_MIX_2		"WPA_AES_WPA2_TKIPAES"
#define WLAN_ENC_METHOD_TKIP_AES_MIX_3		"WPA_TKIP_WPA2_AES"
#define WLAN_ENC_METHOD_TKIP_AES_MIX_4		"WPA_TKIP_WPA2_TKIPAES"
#define WLAN_ENC_METHOD_TKIP_AES_MIX_5		"WPA_TKIPAES_WPA2_AES"
#define WLAN_ENC_METHOD_TKIP_AES_MIX_6		"WPA_TKIPAES_WPA2_TKIP"
#define WLAN_ENC_METHOD_TKIP_AES_MIX_7		"WPA_TKIPAES_WPA2_TKIPAES"

#define WLAN_WSC_ENABLE						"WscEnable"
#define WLAN_WSC_CONFIGED					"WscConfiged"
#define WLAN_WSC_CONF_MODE					"WscConfMode"
#define WLAN_WSC_V2_SUPPORT					"WscV2Support"
#define WLAN_WSC_CONF_STATUS				"WscConfStatus"
#define WLAN_WSC_MODE						"WscMode"
#define WLAN_WSC_PIN_CODE					"WscPinCode"
#define WLAN_WSC_VENDOR_PIN_CODE			"WscVendorPinCode"
#define WLAN_WSC_GET_CONF					"WscGetConf"
#define WLAN_WSC_GEN_PIN_CODE				"WscGenPinCode"

#define WLAN_WSC_CONF_STATUS_VAL_CONFD		"1"
#define WLAN_WSC_CONF_STATUS_VAL_UNCONFD	"2"

#define WLAN_WSC_MODE_VAL_PIN				"1"
#define WLAN_WSC_MODE_VAL_PBC				"2"

#define WLAN_AP_SSID_KEY					"SSID"
#define WLAN_AP1_SSID_KEY					"SSID1"
#define WLAN_AP_WL_MODE_KEY					"WirelessMode"
#define WLAN_AP_HTBW_KEY					"HtBw"
#define WLAN_AP_HTBW_CFG_KEY				"HT_BW"
#define WLAN_AP_VHTBW_KEY					"VhtBw"
#define WLAN_AP_VHTBW_CFG_KEY				"VHT_BW"
#define WLAN_AP_HTBSSCOEX_KEY				"HtBssCoex"
#define WLAN_AP_HTBSSCOEX_CFG_KEY			"HT_BSSCoexistence"
#define WLAN_AP_SGI_KEY						"HtGi"
#define WLAN_AP_SGI_CFG_KEY					"HT_GI"
#define WLAN_AP_VHT_SGI_CFG_KEY				"VHT_SGI"
#define WLAN_AP_TXPOWER_KEY					"TxPower"
#define WLAN_AP_CHANNEL_KEY					"Channel"
#define WLAN_AP_AUTO_CH_SEL_KEY				"AutoChannelSelect"
#define WLAN_AP_BEACON_PERIOD_KEY			"BeaconPeriod"
#define WLAN_AP_HIDE_SSID_KEY				"HideSSID"
#define WLAN_AP_STA_ISOLATE_KEY				"NoForwarding"
#define WLAN_AP_STA_ISOLATE_BTNBSSID_KEY	"NoForwardingBTNBSSID"
#define WLAN_AP_AUTH_MODE_KEY				"AuthMode"
#define WLAN_AP_ENC_TYPE_KEY				"EncrypType"
#define WLAN_AP_ENC_WPA_MIX_KEY				"WpaMixPairCipher"
#define WLAN_AP_ENC_WEP_DEFAULT_KEY_ID_KEY	"DefaultKeyID"
#define WLAN_AP_ENC_WEP_KEY1_KEY			"Key1"
#define WLAN_AP_ENC_WEP_KEY2_KEY			"Key2"
#define WLAN_AP_ENC_WEP_KEY3_KEY			"Key3"
#define WLAN_AP_ENC_WEP_KEY4_KEY			"Key4"
#define WLAN_AP1_ENC_WEP_KEY1_STR_KEY		"Key1Str1"
#define WLAN_AP_ENC_WEP_KEY1_TYPE_KEY		"Key1Type"
#define WLAN_AP1_ENC_WEP_KEY2_STR_KEY		"Key2Str1"
#define WLAN_AP_ENC_WEP_KEY2_TYPE_KEY		"Key2Type"
#define WLAN_AP1_ENC_WEP_KEY3_STR_KEY		"Key3Str1"
#define WLAN_AP_ENC_WEP_KEY3_TYPE_KEY		"Key3Type"
#define WLAN_AP1_ENC_WEP_KEY4_STR_KEY		"Key4Str1"
#define WLAN_AP_ENC_WEP_KEY4_TYPE_KEY		"Key4Type"
#define WLAN_AP_ENC_WPAPSK_KEY				"WPAPSK"
#define WLAN_AP1_ENC_WPAPSK_KEY				"WPAPSK1"
#define WLAN_AP_ACCESS_POLICY_KEY			"AccessPolicy"
#define WLAN_AP1_ACCESS_POLICY_KEY			"AccessPolicy0"
#define WLAN_AP_ACL_ADD_ENTRY_KEY			"ACLAddEntry"
#define WLAN_AP1_ACL_STRING_KEY				"AccessControlList0"
#define WLAN_AP_ACL_CLEAR_ALL_KEY			"ACLClearAll"
#define WLAN_AP_APSD_CAPABLE				"APSDCapable"
#define	WLAN_AP_DLS_CAPABLE					"DLSCapable"
#define WLAN_AP_BG_PROTECTION				"BGProtection"
#define WLAN_AP_HT_EXTCHA					"HtExtcha"
#define WLAN_AP1_HT_EXTCHA					"HT_EXTCHA"
#define WLAN_AP_REKEY_INTERVAL				"RekeyInterval"
#define	WLAN_AP_REKEY_METHOD				"RekeyMethod"
#define WLAN_AP_RTSTHRESHOLD				"RTSThreshold"
#define WLAN_AP_FRAGTHRESHOLD				"FragThreshold"
#define WLAN_AP_DTIMPERIOD					"DtimPeriod"
#define WLAN_AP_TXBURST						"TxBurst"
#define WLAN_AP_PKTAGGREGATE				"PktAggregate"
#define WLAN_AP_GREENAP						"GreenAP"
#define WLAN_AP_GREENFIELD					"HtOpMode"
#define WLAN_AP1_GREENFIELD					"HT_OpMode"
#define WLAN_AP_RADIOON						"RadioOn"
#define WLAN_AP_COUNTRY_CODE				"CountryCode"
#define WLAN_AP_COUNTRYREGIONFORABAND		"CountryRegionABand"
#define WLAN_AP_COUNTRYREGION				"CountryRegion"
#define WLAN_AP_COUNTRYNUM					"CountryNum"

#define WLAN_CLI_ENABLE_KEY					"ApCliEnable"
#define WLAN_CLI_SSID_KEY					"ApCliSsid"
#define WLAN_CLI_BSSID_KEY					"ApCliBssid"
#define WLAN_CLI_AUTH_MODE_KEY				"ApCliAuthMode"
#define WLAN_CLI_ENC_TYPE_KEY				"ApCliEncrypType"
#define WLAN_CLI_ENC_WEP_DEFAULT_KEY_ID_KEY	"ApCliDefaultKeyID"
#define WLAN_CLI_ENC_WEP_KEY1_KEY			"ApCliKey1"
#define WLAN_CLI_ENC_WEP_KEY2_KEY			"ApCliKey2"
#define WLAN_CLI_ENC_WEP_KEY3_KEY			"ApCliKey3"
#define WLAN_CLI_ENC_WEP_KEY4_KEY			"ApCliKey4"
#define WLAN_CLI_ENC_WEP_KEY1_STR_KEY		"ApCliKey1Str"
#define WLAN_CLI_ENC_WEP_KEY1_TYPE_KEY		"ApCliKey1Type"
#define WLAN_CLI_ENC_WEP_KEY2_STR_KEY		"ApCliKey2Str"
#define WLAN_CLI_ENC_WEP_KEY2_TYPE_KEY		"ApCliKey2Type"
#define WLAN_CLI_ENC_WEP_KEY3_STR_KEY		"ApCliKey3Str"
#define WLAN_CLI_ENC_WEP_KEY3_TYPE_KEY		"ApCliKey3Type"
#define WLAN_CLI_ENC_WEP_KEY4_STR_KEY		"ApCliKey4Str"
#define WLAN_CLI_ENC_WEP_KEY4_TYPE_KEY		"ApCliKey4Type"
#define WLAN_CLI_ENC_WPAPSK_KEY				"ApCliWPAPSK"

#define DEFAULT_OPT_MODE					"2"	/* Repeater Mode */

#define DEFAULT_LED_POWER_SAVE_ON			"N"

#define DEFAULT_TZ							"66"
#define DEFAULT_NTPSERVER					"pool.ntp.org"

#define DEFAULT_WLAN_24G_AP_SSID			"Askey"
#define DEFAULT_WLAN_24G_AP_WL_MODE			"7"
#define DEFAULT_WLAN_24G_AP_HTBW			"1"
#define DEFAULT_WLAN_24G_AP_VHTBW			"0"
#define DEFAULT_WLAN_24G_AP_HTGI			"1"
#define DEFAULT_WLAN_24G_AP_TXPOWER			"100"
#define DEFAULT_WLAN_24G_AP_CHANNEL			"6"
#define DEFAULT_WLAN_24G_AP_AUTO_CHANNEL	"1"
#define DEFAULT_WLAN_24G_AP_BEACON_PERIOD	"100"
#define DEFAULT_WLAN_24G_AP_HIDE_SSID		"0"
#define DEFAULT_WLAN_24G_AP_STA_ISOLATE		"0"
#define DEFAULT_WLAN_24G_AP_AUTH_MODE		"OPEN"
#define DEFAULT_WLAN_24G_AP_ENC_TYPE		"NONE"
#define DEFAULT_WLAN_24G_AP_ENC_WPAMIX		""
#define DEFAULT_WLAN_24G_AP_KEY_ID			"1"
#define DEFAULT_WLAN_24G_AP_KEY_STR			"12345"
#define DEFAULT_WLAN_24G_AP_KEY_TYPE		"1"
#define DEFAULT_WLAN_24G_AP_WPAPSK			"12345678"
#define DEFAULT_WLAN_24G_AP_ACL_TYPE		"0"
#define DEFAULT_WLAN_24G_AP_ACL_STR			""
#define DEFAULT_WLAN_24G_AP_APSD_CAPABLE	"0"
#define DEFAULT_WLAN_24G_AP_DLS_CAPABLE		"0"
#define DEFAULT_WLAN_24G_AP_BG_PROTECTION	"0"
#define DEFAULT_WLAN_24G_AP_HT_EXTCHA		"0"
#define DEFAULT_WLAN_24G_AP_REKEY_INTERVAL	"3600"
#define DEFAULT_WLAN_24G_AP_REKEY_METHOD	"TIME"
#define DEFAULT_WLAN_24G_AP_RTSTHRESHOLD	"2347"
#define DEFAULT_WLAN_24G_AP_FRAGTHRESHOLD	"2346"
#define DEFAULT_WLAN_24G_AP_DTIMPERIOD		"1"
#define DEFAULT_WLAN_24G_AP_TXBURST			"1"
#define DEFAULT_WLAN_24G_AP_PKTAGGREGATE	"1"
#define DEFAULT_WLAN_24G_AP_GREENAP			"0"
#define DEFAULT_WLAN_24G_AP_GREENFIELD		"0"
#define DEFAULT_WLAN_24G_AP_RADIOON			"1"
#define DEFAULT_WLAN_24G_AP_REGIONFORABAND	"7"
#define DEFAULT_WLAN_24G_AP_REGION			"5"
#define DEFAULT_WLAN_24G_AP_COUNTRYCODE		"TW"
#define DEFAULT_WLAN_24G_AP_WSC_ENABLE		"0"
#define DEFAULT_WLAN_24G_AP_WSC_CONFIGED	"0"

#define DEFAULT_WLAN_5G_AP_SSID				"Askey5G"
#define DEFAULT_WLAN_5G_AP_WL_MODE			"15"
#define DEFAULT_WLAN_5G_AP_HTBW				"1"
#define DEFAULT_WLAN_5G_AP_VHTBW			"1"
#define DEFAULT_WLAN_5G_AP_HTGI				"1"
#define DEFAULT_WLAN_5G_AP_TXPOWER			"100"
#define DEFAULT_WLAN_5G_AP_CHANNEL			"0"
#define DEFAULT_WLAN_5G_AP_AUTO_CHANNEL		"1"
#define DEFAULT_WLAN_5G_AP_BEACON_PERIOD	"100"
#define DEFAULT_WLAN_5G_AP_HIDE_SSID		"0"
#define DEFAULT_WLAN_5G_AP_STA_ISOLATE		"0"
#define DEFAULT_WLAN_5G_AP_AUTH_MODE		"OPEN"
#define DEFAULT_WLAN_5G_AP_ENC_TYPE			"NONE"
#define DEFAULT_WLAN_5G_AP_ENC_WPAMIX		""
#define DEFAULT_WLAN_5G_AP_KEY_ID			"1"
#define DEFAULT_WLAN_5G_AP_KEY_STR			"12345"
#define DEFAULT_WLAN_5G_AP_KEY_TYPE			"1"
#define DEFAULT_WLAN_5G_AP_WPAPSK			"12345678"
#define DEFAULT_WLAN_5G_AP_ACL_TYPE			"0"
#define DEFAULT_WLAN_5G_AP_ACL_STR			""
#define DEFAULT_WLAN_5G_AP_APSD_CAPABLE		"0"
#define DEFAULT_WLAN_5G_AP_DLS_CAPABLE		"0"
#define DEFAULT_WLAN_5G_AP_BG_PROTECTION	"0"
#define DEFAULT_WLAN_5G_AP_HT_EXTCHA		"0"
#define DEFAULT_WLAN_5G_AP_REKEY_INTERVAL	"3600"
#define DEFAULT_WLAN_5G_AP_REKEY_METHOD		"TIME"
#define DEFAULT_WLAN_5G_AP_RTSTHRESHOLD		"2347"
#define DEFAULT_WLAN_5G_AP_FRAGTHRESHOLD	"2346"
#define DEFAULT_WLAN_5G_AP_DTIMPERIOD		"1"
#define DEFAULT_WLAN_5G_AP_TXBURST			"1"
#define DEFAULT_WLAN_5G_AP_PKTAGGREGATE		"1"
#define DEFAULT_WLAN_5G_AP_GREENAP			"0"
#define DEFAULT_WLAN_5G_AP_GREENFIELD		"0"
#define DEFAULT_WLAN_5G_AP_RADIOON			"1"
#define DEFAULT_WLAN_5G_AP_REGIONFORABAND	"7"
#define DEFAULT_WLAN_5G_AP_REGION			"5"
#define DEFAULT_WLAN_5G_AP_COUNTRYCODE		"TW"
#define DEFAULT_WLAN_5G_AP_WSC_ENABLE		"0"
#define DEFAULT_WLAN_5G_AP_WSC_CONFIGED		"0"

#define DEFAULT_WLAN_24G_CLI_ENABLE			"1"
#define DEFAULT_WLAN_24G_CLI_SSID			"AskeyWifi"
#define DEFAULT_WLAN_24G_CLI_BSSID			""
#define DEFAULT_WLAN_24G_CLI_AUTH_MODE		"OPEN"
#define DEFAULT_WLAN_24G_CLI_ENC_TYPE		"NONE"
#define DEFAULT_WLAN_24G_CLI_KEY_ID			"1"
#define DEFAULT_WLAN_24G_CLI_KEY_STR		"12345"
#define DEFAULT_WLAN_24G_CLI_KEY_TYPE		"1"
#define DEFAULT_WLAN_24G_CLI_WPAPSK			"12345678"

#define DEFAULT_WLAN_5G_CLI_ENABLE			"0"
#define DEFAULT_WLAN_5G_CLI_SSID			"AskeyWifi5G"
#define DEFAULT_WLAN_5G_CLI_BSSID			""
#define DEFAULT_WLAN_5G_CLI_AUTH_MODE		"OPEN"
#define DEFAULT_WLAN_5G_CLI_ENC_TYPE		"NONE"
#define DEFAULT_WLAN_5G_CLI_KEY_ID			"1"
#define DEFAULT_WLAN_5G_CLI_KEY_STR			"12345"
#define DEFAULT_WLAN_5G_CLI_KEY_TYPE		"1"
#define DEFAULT_WLAN_5G_CLI_WPAPSK			"12345678"

#define DEFAULT_LAN_CONNECT_TYPE			CONNTYPE_VAL_DHCP

#define DEFAULT_LAN_STATIC_IP				PF_DEP_DEFAULT_IP_ADDR
#define DEFAULT_LAN_STATIC_MASK				PF_DEP_DEFAULT_NET_MASK
#define DEFAULT_LAN_STATIC_GW				PF_DEP_DEFAULT_GATEWAY

#define DEFAULT_NETCFG_MTU					"0"
#define DEFAULT_NETCFG_MANUAL_DNS			"0"
#define DEFAULT_NETCFG_DEFAULT_DNS1			"8.8.8.8"
#define DEFAULT_NETCFG_DEFAULT_DNS2			""

#define DEFAULT_NETCFG_DHCPD_TYPE			"1"
#define DEFAULT_NETCFG_DHCPD_POOL_START		"192.168.2.100"
#define DEFAULT_NETCFG_DHCPD_POOL_END		"192.168.2.200"
#define DEFAULT_NETCFG_DHCPD_NETMASK		"255.255.255.0"
#define DEFAULT_NETCFG_DHCPD_DEFAULT_GW		PF_DEP_DEFAULT_IP_ADDR
#define DEFAULT_NETCFG_DHCPD_LEASE			"120"
#define DEFAULT_NETCFG_DHCPD_DNS1			PF_DEP_DEFAULT_IP_ADDR
#define DEFAULT_NETCFG_DHCPD_DNS2			"8.8.8.8"

#ifndef	O_BINARY
#define O_BINARY	0
#endif

/* Type definitions. */

	enum {
		MTK_LED_5G_SIGNAL_LOW,
		MTK_LED_5G_SIGNAL_NORMAL,
		MTK_LED_5G_SIGNAL_HIGH,
		MTK_LED_24G_SIGNAL_LOW,
		MTK_LED_24G_SIGNAL_NORMAL,
		MTK_LED_24G_SIGNAL_HIGH,
		MTK_LED_SYSTEM_POWER,
		MTK_LED_MAX,
	} etmk_led;

	enum {
		MTK_LED_GROUP_ALL,
		MTK_LED_GROUP_5G_SIGNAL,
		MTK_LED_GROUP_24G_SIGNAL,
		MTK_LED_GROUP_MAX,
	} emkt_led_group;

	typedef struct CountryCodeToCountryRegion {
		unsigned int CountryNum;
		char IsoName[3];
		char pCountryName[40];
		e_bool SupportABand;
		unsigned char RegDomainNum11A;
		e_bool SupportGBand;
		unsigned char RegDomainNum11G;
	} COUNTRY_CODE_TO_COUNTRY_REGION;

	enum {
		A_BAND_REGION_0,
		A_BAND_REGION_1,
		A_BAND_REGION_2,
		A_BAND_REGION_3,
		A_BAND_REGION_4,
		A_BAND_REGION_5,
		A_BAND_REGION_6,
		A_BAND_REGION_7,
		A_BAND_REGION_8,
		A_BAND_REGION_9,
		A_BAND_REGION_10,
	} e5g_band_region;

	enum {
		G_BAND_REGION_0,
		G_BAND_REGION_1,
		G_BAND_REGION_2,
		G_BAND_REGION_3,
		G_BAND_REGION_4,
		G_BAND_REGION_5,
		G_BAND_REGION_6,
	} e24g_band_region;

/* External function declarations. */

	extern e_ret init_rlt_wifi_dev(tdp_dev * dp_dev);
	extern e_ret init_rt2860v2_ap_dev(tdp_dev * dp_dev);

	extern void cleanup_wlan24g_ap_if(tdata_paths * dp);
	extern void cleanup_wlan5g_ap_if(tdata_paths * dp);
	extern void cleanup_wlan24g_cli_if(tdata_paths * dp);
	extern void cleanup_wlan5g_cli_if(tdata_paths * dp);
	extern void cleanup_eth2_if(tdata_paths * dp);
	extern void cleanup_eth2_vid1_if(tdata_paths * dp);
	extern void cleanup_eth2_vid2_if(tdata_paths * dp);
	extern void cleanup_lan_br_if(tdata_paths * dp);

	extern e_ret init_lan_br_if_link(tdata_paths * dp);
	extern e_ret init_lan_br_if_net(tdata_paths * dp);
	extern e_ret init_eth2_vid2_if(tdata_paths * dp);
	extern e_ret init_eth2_vid1_if(tdata_paths * dp);
	extern e_ret init_eth2_if(tdata_paths * dp);
	extern e_ret init_wlan5g_cli_if(tdata_paths * dp);
	extern e_ret init_wlan24g_cli_if(tdata_paths * dp);
	extern e_ret init_wlan5g_ap_if(tdata_paths * dp);
	extern e_ret init_wlan24g_ap_if(tdata_paths * dp);

	extern unsigned char pd_dep_wlmode_to_wlmode_24g(const char *wlmode);
	extern unsigned char pd_dep_wlmode_to_wlmode_5g(const char *wlmode);
	extern const char *wlmode_to_pd_dep_wlmode_24g(unsigned char wlmode, char *pf_dep_wlmode);
	extern const char *wlmode_to_pd_dep_wlmode_5g(unsigned char wlmode, char *pf_dep_wlmode);

	extern unsigned char pd_dep_bw_to_bw(const char *pf_dep_htbw, const char *pf_dep_vhthw);
	extern const char *bw_to_pd_dep_bw(unsigned char bw, char *pf_dep_htbw, char *pf_dep_vhthw);

	extern unsigned char pd_dep_authmode_to_authmode(const char *pf_dep_authmode);
	extern const char *authmode_to_pd_dep_authmode(unsigned char authmode, char *pf_dep_authmode);
	extern unsigned char pd_dep_enctype_to_enctype(unsigned char auth_mode,
						       const char *pf_dep_enctype, const char *pf_dep_enctype_wpamix);
	extern const char *enctype_to_pd_dep_enctype(unsigned char enctype,
						     unsigned char auth_mode, char *pf_dep_enctype,
						     char *pf_dep_enctype_wpamix);
	extern unsigned char pd_dep_bgprotect_to_bgprotect(const char *pf_dep_bgprotect);

	extern const char *conntype_to_pf_dep_conntype(unsigned char conntype, char *pf_dep_conntype);
	extern unsigned char pf_dep_conntype_to_conntype(const char *pf_dep_conntype);

#ifdef APCLI_BOND_SUPPORT
	extern e_ret dp_if_bond_member_opt(const char *if_name, unsigned char add);
	extern e_ret add_apcli_bond_if_to_br(tdata_paths * dp);
#endif				/* APCLI_BOND_SUPPORT */

	extern e_ret dp_if_set_bridge_uplink(const char *if_name);
	extern e_ret dp_if_add_bridge_member(const char *if_name);
	extern e_ret dp_if_del_bridge_member(const char *if_name);

	extern e_ret init_lan_br_if_qis_net(e_bool done);

	extern e_ret mtk_gpio_set_dir(int dev_fd, unsigned char gpio, unsigned char dir);
	extern e_ret mtk_gpio_read(int dev_fd, unsigned char gpio, unsigned long *val);
	extern e_ret mtk_gpio_write(int dev_fd, unsigned char gpio, unsigned long val);
	extern e_ret mtk_gpio_set_irq(int dev_fd, unsigned char enable);
	extern e_ret mtk_gpio_reg_proc(int dev_fd, unsigned char gpio, unsigned long pid);
	extern e_ret mtk_gpio_get_intp(int dev_fd, unsigned char gpio, unsigned char *intp);
	extern e_ret mtk_gpio_set_led(int dev_fd, unsigned char gpio, tled_cfg * led);

	extern int raesw_init(void);
	extern void raesw_finish(int fd);
	extern int raesw_reg_write(int fd, int offset, int value);
	extern int raesw_reg_read(int fd, int offset, int *value);
	extern int raesw_vlan_set(int fd, int idx, int vid, unsigned int portmap,
				  int stag, e_bool eg_con_enable, e_bool eg_tag_control);
	extern void raesw_table_clear(int fd);

/* Macro API definitions. */

#define pf_dep_cfg_get_val(index, name, default_val) \
({																			\
	const char* cfg_val;													\
	cfg_val = nvram_bufget((index), (name));								\
	if ((cfg_val == NULL) || (cfg_val[0] == 0)) {							\
		sysmgr_dbg("nvram_bufget(%d, %s) == [%s] use default:[%s]\n",		\
			(index), (name), cfg_val, default_val);							\
		cfg_val = (default_val);											\
	} else {																\
		sysmgr_dbg("nvram_bufget(%d, %s) == [%s]\n", (index), (name),		\
			cfg_val);														\
	}																		\
	cfg_val;																\
})

#define pf_dep_cfg_set_val(index, name, new_val) \
({																			\
	int return_code = 0;													\
	const char* const old_val = nvram_bufget((index), (name));				\
	if ((old_val == NULL) || (strcmp(old_val, new_val) != 0)) {			\
		return_code = nvram_bufset((index), (name), (new_val));			\
		sysmgr_dbg("nvram_bufset(%d, %s, %s) rc: %d.\n",					\
			(index), (name), (new_val), return_code);						\
	} else {																\
		sysmgr_dbg("nvram_bufset(%d, %s, %s) same value: old[%s].\n",		\
			(index), (name), (new_val), (old_val));						\
	}																		\
	return_code;															\
})

#define do_iwpriv(iwif, action, arg) \
({																				\
	int rc = iwpriv((iwif), (action), (arg));									\
	sysmgr_dbg("iwpriv([%s] [%s] [%s]) rc:%d.\n", (iwif), (action), (arg), rc); \
	rc; 																		\
})

/* Global variable declarations. */

#ifdef __cplusplus
}				/* extern "C" */
#endif				/* __cplusplus */
#endif				/* __PLATFORM_MTK7620_LOCAL_H__ */
